package com.itheima.inetaddressdemo;

import java.net.InetAddress;

public class InetAddressDemo1 {

    public static void main(String[] args) throws Exception {
        // 获取本地的InetAddress对象
        InetAddress inetAddress1 = InetAddress.getLocalHost();
        System.out.println(inetAddress1);

        // 获取远程的InetAddress对象
        InetAddress inetAddress = InetAddress.getByName("www.baidu.com");
        System.out.println(inetAddress);

        // 判断本地InetAddress对象是否和远程InetAddress是否互通
        boolean isReachable = inetAddress.isReachable(3000);
        System.out.println(isReachable);

    }

}
